package comAPIdlw.service;

import com.alibaba.fastjson.JSONObject;
import comAPIdlw.Constants;
import comAPIdlw.bean.HotVideo;
import comAPIdlw.bean.HotVideoComm;
import comAPIdlw.request.HttpUtils;

import java.util.List;

/**
 * @Author: dlw
 * @QQ : 1595507337
 * @desc:
 * @Date: 2021/12/4 11:43
 */

/**
 * 该方法获取热门数据，并将热门数据返回
 */
public class HotVideoService {
       public List<HotVideo> getHotVideo(){
           String url= Constants.TRIP_URL
                   + "?key=" + Constants.TRIP_KEY
                   + "&type=hot_video"
                   +"&size=20";

           String  result= HttpUtils.get(url);
           System.out.println(result);

           //JISO解析    将result解析成类对象
           HotVideoComm videoComm = JSONObject.parseObject(result, HotVideoComm.class);

//           System.out.println(videoComm.reason);
//           System.out.println(videoComm.error_code);
          // System.out.println(videoComm.result.size());
              //返回热门视频结果
           return videoComm.result;
       }
}
